#!/usr/bin/python2.4

# C6304: copyright missing
# pylint: disable-msg=C6304

"""Reads image files for tidal current and wind forecast, and others."""

import optparse

import dfoimagereader
import uwimagereader
def SetUpOptions():
  p = optparse.OptionParser()
  p.add_option(
      '--trace_level',
      default=0,
      help='Trace level.')

  p.add_option(
      '--dfo',
      default=False,
      action="store_true",
      help='Read and convert tidal current predictions from CDN DFO '
          '(Department of Fisheries and Oceanography).')

  p.add_option(
      '--uw',
      default=False,
      action="store_true",
      help='Read and convert wind predictions from '
          'UW Atmos Sciences WRF forecasts.')

  p.add_option(
      '--getdfo',
      default=False,
      action="store_true",
      help='Download current predictions from CDN DFO.')

  p.add_option(
      '--getuw',
      default=False,
      action="store_true",
      help='Download current predictions from UW WRF.')

  p.add_option(
      '--desired',
      default='today',
      help='The name of the set of data to download; use in conjunction with '
          '--getdfo and --getuw')

  options, args = p.parse_args()
  # print 'options=%s args=%s' % (options, args)
  return (options, args)


def main():
  options, unused_args = SetUpOptions()

  language = 'eng'
  # tesseract_api = pywraptesseract.TesseractCobraAPI(language)
  tesseract_api = None

  if options.getuw:
    uwimagereader.ReadGIFFromUW(options.desired)

  if options.getdfo:
    dfoimagereader.ReadGIFFromDFO(options.desired)

  if options.uw:
    reader = uwimagereader.UWImageReader(tesseract_api)
    output_file_name = uwimagereader.GetSummaryCSVFileName()
    output_file = open(output_file_name, 'w')
    reader.ReadImages(options.desired, output_file)
    output_file.close()

  if options.dfo:
    reader = dfoimagereader.DFOImageReader(tesseract_api)
    output_file_name = dfoimagereader.GetSummaryCSVFileName()
    output_file = open(output_file_name, 'w')
    reader.ReadImages(options.desired, output_file)
    output_file.close()


if __name__ == '__main__':
  main()
